import java.io.*;
import java.util.*;

public class Main {
	String input;
	BufferedReader bf;
	StringTokenizer st;
	StringBuilder sb = new StringBuilder();
	
	String[] note = new String[] {
		"C",	"C#",	"D",	"D#",
		"E",	"F",	"F#",	"G",
		"G#",	"A",	"A#",	"B"
	};
	int n;
	
	public static void main(String[] args) {
		Main main = new Main();
		main.beginProcess();
	}

	public void beginProcess() {
		bf = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			input = bf.readLine();
			st = new StringTokenizer(input);
			n = Integer.parseInt(st.nextToken());
			
			while(n != 0) {
				input = bf.readLine();
				
				getChord(input);
				
				n--;
			}
			
			System.out.print(sb);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void getChord(String input) {
		String pitch;
		int i,
			len = note.length,
			pos = 0;
		
		st = new StringTokenizer(input);
		pitch = st.nextToken();
		
		if(pitch.length() == 1) {
			sb.append(pitch + " ");
			for(i = 0; i < len; i++) {
				if(note[i].equals(pitch)) {
					pos = i;
					break;
				}
			}

			if(pos + 4 <= len - 1) {
				pos += 4;
			} else {
				pos = (pos + 4) % len;
			}
			sb.append(note[pos] + " ");

			if(pos + 3 <= len - 1) {
				pos += 3;
			} else {
				pos = (pos + 3) % len;
			}
			sb.append(note[pos] + "\n");
		}
		else if(pitch.length() == 2) {
			if(pitch.substring(1, 2).equals("#")) {
				sb.append(pitch + " ");
				for(i = 0; i < len; i++) {
					if(note[i].equals(pitch)) {
						pos = i;
						break;
					}
				}

				if(pos + 4 <= len - 1) {
					pos += 4;
				} else {
					pos = (pos + 4) % len;
				}
				sb.append(note[pos] + " ");

				if(pos + 3 <= len - 1) {
					pos += 3;
				} else {
					pos = (pos + 3) % len;
				}
				sb.append(note[pos] + "\n");				
			} else {
				pitch = pitch.substring(0, 1);
				sb.append(pitch + " ");
				for(i = 0; i < len; i++) {
					if(note[i].equals(pitch)) {
						pos = i;
						break;
					}
				}

				if(pos + 3 <= len - 1) {
					pos += 3;
				} else {
					pos = (pos + 3) % len;
				}
				sb.append(note[pos] + " ");

				if(pos + 4 <= len - 1) {
					pos += 4;
				} else {
					pos = (pos + 4) % len;
				}
				sb.append(note[pos] + "\n");
			}
		}
		else if(pitch.length() == 3) {
			pitch = pitch.substring(0, 2);
			sb.append(pitch + " ");
			for(i = 0; i < len; i++) {
				if(note[i].equals(pitch)) {
					pos = i;
					break;
				}
			}

			if(pos + 3 <= len - 1) {
				pos += 3;
			} else {
				pos = (pos + 3) % len;
			}
			sb.append(note[pos] + " ");

			if(pos + 4 <= len - 1) {
				pos += 4;
			} else {
				pos = (pos + 4) % len;
			}
			sb.append(note[pos] + "\n");
		}
	}
	
}